//初始化数据
const app = getApp()

Page({
  data:{
    user_type:1
  }
  
})
function aa()
{
  wx.getStorage({
    key: 'enteraccount',
    success(res) {
      app.globalData.user_type = 1
      ;
    }
  })
  
}
function tabbarinit() {
  try {
    var value = wx.getStorageSync('enteraccount')
    if (value) {
      return [
        {
          "current": 0,
          "pagePath": "/pages/first/pages/shou/index",
          "text": "首页",
          "iconPath": "/image/icon_component.png",
          "selectedIconPath": "/image/icon_component_HL.png"
        },
        {
          "current": 0,
          "pagePath": "/pages/first/pages/campus/campus",
          "text": "招聘",
          "iconPath": "/image/icon_API.png",
          "selectedIconPath": "/image/icon_API_HL.png"
        },
        {
          "current": 0,
          "pagePath": "/pages/second/find/find",
          "text": "发现",
          "iconPath": "/image/20.png",
          "selectedIconPath": "/image/21.png"

        },
        {
          "current": 0,
          "pagePath": "/pages/companyheart/company/company",
          "text": "企业中心",
          "iconPath": "/images/首页.png",
          "selectedIconPath": "/images/首页2.png",
          "selectedColor": "#4EDF80"
        }
      ]
    }else
    {
      return [
        {
          "current": 0,
          "pagePath": "/pages/first/pages/shou/index",
          "text": "首页",
          "iconPath": "/image/icon_component.png",
          "selectedIconPath": "/image/icon_component_HL.png"
        },
        {

          "current": 0,

          "pagePath": "/pages/first/pages/campus/campus",
          "text": "招聘",
          "iconPath": "/image/icon_API.png",
          "selectedIconPath": "/image/icon_API_HL.png"
        },
        {
          "current": 0,
          "pagePath": "/pages/second/find/find",
          "text": "发现",
          "iconPath": "/image/20.png",
          "selectedIconPath": "/image/21.png"

        },
        {
          "current": 0,
          "pagePath": "/pages/self/company/company",
          "text": "我的",
          "iconPath": "/image/24.png",
          "selectedIconPath": "/image/19.png",
          "selectedColor": "#4EDF80"
        }
      ]
    }
  } catch (e) {
    
  }
  
}

//tabbar 主入口

function tabbarmain(bindName = "tabdata", id, target) {

  var that = target;

  var bindData = {};

  var otabbar = tabbarinit();
  if (getApp().globalData.user_type == 1){
  otabbar[3]['text'] = '企业中心',
    otabbar[3]['pagePath'] = "/pages/companyheart/company/company",
    otabbar[0]['iconPath'] = "/images/首页.png",
    otabbar[0]['selectedIconPath'] = "/images/首页2.png"
   
  }
    otabbar[id]['iconPath'] = otabbar[id]['selectedIconPath']//换当前的icon

    otabbar[id]['current'] = 1;

    bindData[bindName] = otabbar

    that.setData({ bindData });

 

}



module.exports = {

  tabbar: tabbarmain

}